<template>
  <div class="take-order">
    <TakeOrderItem v-for="item in list" :key="item.id" :listItem="item"></TakeOrderItem>
  </div>
</template>

<script>
import TakeOrderItem from '@/components/maintainer/TakeOrderItem.vue'
import { takeOrderListService } from '@/api/maintainer'
export default {
  data () {
    return {
      list: []
    }
  },
  created () {
    this.takeOrderlist()
  },
  methods: {
    async takeOrderlist () {
      const res = await takeOrderListService()
      if (res.status === 1) return
      res.data.forEach((item, index, arr) => {
        switch (item.order_status) {
          case '1':
            item.order_status = '等待接单'
            return
          case '2':
            item.order_status = '预约成功'
            return
          case '3':
            item.order_status = '进行中'
            return
          case '4':
            item.order_status = '已完成'
            return
          case '5':
            item.order_status = '待评价'
            return
          default:
            item.order_status = '未知'
        }
      })
      this.list = res.data
    }
  },
  components: {
    TakeOrderItem
  }
}
</script>

<style lang="less" scoped></style>
